package com.teambsc4.todo.model

import androidx.room.*
import com.teambsc4.todo.entities.TaskItem
import okhttp3.internal.concurrent.Task

/**
 * @projectName: Dao
 * @package: com.teambsc4.todo.entities
 * @className: TaskItemDao
 * @author: Eric
 * @description: TODO
 * @version: 1.0
 */
@Dao
interface TaskItemDao {

    //increase
    @Insert
    fun insertTask(insertTask: TaskItem)

    //Delete
    @Delete
    suspend fun deleteTask(task: TaskItem)

    //Update
    @Update
    fun update(taskItem: TaskItem)


    @Query("DELETE FROM task WHERE id = :id")
    fun deleteById(id: Int)


    @Query("SELECT * FROM task WHERE id = :taskId")
    fun queryById(taskId: Int): TaskItem

    //Query
    @Query("SELECT * FROM task ORDER BY status DESC, priority ASC , CAST(endTime AS INTEGER) ASC")
    fun queryAll(): List<TaskItem>


}